package com.dt76.smallloanbackendservice.service.lhuaw.impl;

import com.dt76.smallloanbackendservice.mapper.lhuaw.TextMessageMapper;
import com.dt76.smallloanbackendservice.pojo.lhuaw.TextMessage;
import com.dt76.smallloanbackendservice.service.lhuaw.TextMessageService;
import com.dt76.smallloanbackendservice.utils.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TextMessageServiceImpl implements TextMessageService {

    @Autowired
    private TextMessageMapper textMessageMapper;

    @Override
    public List<TextMessage> getAllText() {
        return textMessageMapper.getAllText();
    }

    @Override
    public Page qryConditionPageAllText(int pageIndex, String tPublisher) {
        Page page = new Page();
        page.setPageIndex(pageIndex);
        page.setTotalCount(textMessageMapper.qryConditionCountText(tPublisher));
        List<TextMessage> textMessageList = textMessageMapper.qryConditionPageAllText((page.getPageIndex() - 1) * page.getPageSize(),
                page.getPageSize(), tPublisher);
        System.out.println(textMessageList);
        page.setRows(textMessageList);
        return page;
    }

    @Override
    public void deleteText(int tId) {
        textMessageMapper.deleteText(tId);
    }
}
